/**
 * Created by zjx on 2017/1/16.
 */
function initDataTable( config_obj ){
    if ( ! isConfigValidated( config_obj ) ) {
        return console.warn('need validate config object')
    }

    $( config_obj.id ).dataTable({
//            bPaginate: false,
        // 按原始数据初始化
        aaSorting: [],
        // 指定需要排序的列
        aoColumns: config_obj.columns,
        oLanguage: {
            "sProcessing": "处理中...",
            "sLengthMenu": "显示 _MENU_ 项结果",
            "sZeroRecords": "没有匹配结果",
            "sInfo": "显示第 _START_ 至 _END_ 项结果，共 _TOTAL_ 项",
            "sInfoEmpty": "显示第 0 至 0 项结果，共 0 项",
            "sInfoFiltered": "(由 _MAX_ 项结果过滤)",
            "sInfoPostFix": "",
            "sSearch": "搜索:",
            "sUrl": "",
            "sEmptyTable": "表中数据为空",
            "sLoadingRecords": "载入中...",
            "sInfoThousands": ",",
            "oPaginate": {
                "sFirst": "首页",
                "sPrevious": "上页",
                "sNext": "下页",
                "sLast": "末页"
            },
            "oAria": {
                "sSortAscending": ": 以升序排列此列",
                "sSortDescending": ": 以降序排列此列"
            }
        }
    });

    $('.dataTables_length select').select2();

    function isConfigValidated( config_obj ){
        return  config_obj &&
                Object.keys(config_obj).length &&
                config_obj.id &&
                config_obj.columns &&
                config_obj.columns.length;
    }
}